<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container>
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="英克采购订单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ykOrderNo">
              <a-input v-model="model.ykOrderNo" :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="细单数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="detailAmount">
              <a-input v-model="model.detailAmount"  :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="订单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderNo">
              <a-input v-model="model.orderNo" :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>

          <a-col :span="12">
            <a-form-model-item label="创建人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderNo">
              <a-input v-model="model.orderNo" :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="供应商名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="supplyName">
              <a-input v-model="model.supplyName"  :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="仓库名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wareName">
              <a-input v-model="model.wareName" :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="12">
            <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="state">
              <a-input v-model="model.state" :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col> -->
        </a-row>
        <div class="scrollable-container">
          <a-card :title="'细单' + (index + 1)" v-for="(item, index) in list" :key="index">
          <a-card-grid style="width: 15%; text-align: left"> 序号： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> {{ item.detailNo }} </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> 英克采购订单号： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> {{ item.ykOrderNo }} </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> 英克采购细单号： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> {{ item.ykOrderDetailNo }} </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> 采购员： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> {{ item.procureName }} </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> 数量： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> {{ item.amount }} </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> 产品名称： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> {{ item.productName }} </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> 生产厂家： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> {{ item.productYlqxzcrbarmc }} </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> 品码： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left">
            {{ item.productZxxsdycpbs ? item.productZxxsdycpbs : '-'}}
          </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> 单位： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> {{ item.unit }} </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> 注册证： </a-card-grid>
          <a-card-grid style="width: 15%; text-align: left"> {{ item.zcz }} </a-card-grid>
        </a-card>
        </div>
       

        <!-- <div v-for="(item, index) in list" :key="index">
          
          <a-row>
            <a-col :span="6">数量：</a-col><a-col :span="12">{{ item.amount }}</a-col>
          </a-row>
          <a-row>
            <a-col :span="6">产品名称：</a-col><a-col :span="12">{{ item.productName }}</a-col>
          </a-row>
          <a-row>
            <a-col :span="6">生产厂家：</a-col><a-col :span="12">{{ item.productYlqxzcrbarmc }}</a-col>
          </a-row>
          <a-row>
            <a-col :span="6">品码：</a-col><a-col :span="12">{{ item.productZxxsdycpbs }}</a-col>
          </a-row>
          <a-row>
            <a-col :span="6">单位：</a-col><a-col :span="12">{{ item.unit }}</a-col>
          </a-row>
          <a-row>
            <a-col :span="6">注册证：</a-col><a-col :span="12">{{ item.zcz }}</a-col>
          </a-row>
        </div> -->
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>
import { httpAction, getAction } from '@/api/manage'
import { queryEffectiveListApi } from '@/api/order'
import { validateDuplicateValue } from '@/utils/util'

export default {
  name: 'SaleOrderForm',
  components: {},
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false,
    },
  },
  data() {
    return {
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {},
      url: {
        add: '/wms/wmsProduct/add',
        edit: '/wms/wmsProduct/edit',
        // queryById: "/wms/wmsProduct/queryById"
      },
      list: [],
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
  },
  mounted() {
   
  },

  methods: {
    add() {
      this.edit(this.modelDefault)
    },
    async inquire() {
      let params = {
        orderNo: this.model.orderNo,
      }
      let res = await queryEffectiveListApi(params)
      if (res.code == 200) {
        console.log(res)
        this.list = res.result.records
      } else {
        this.$message.warning(res.message)
      }
    },
    edit(record) {
      this.model = Object.assign({}, record)
      this.visible = true
      this.inquire()
    },
    submitForm() {
      const that = this
      // 触发表单验证
      this.$refs.form.validate((valid) => {
        if (valid) {
          that.confirmLoading = true
          let httpurl = ''
          let method = ''
          if (!this.model.id) {
            httpurl += this.url.add
            method = 'post'
          } else {
            httpurl += this.url.edit
            method = 'put'
          }
          httpAction(httpurl, this.model, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('ok')
              } else {
                that.$message.warning(res.message)
              }
            })
            .finally(() => {
              that.confirmLoading = false
            })
        }
      })
    },
  },
}
</script>

<style scoped lang="scss">
.ant-card-grid {
  padding: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ant-card-grid:nth-child(odd) {
  background-color: rgb(243, 245, 246);
}

.ant-card-grid:hover {
  text-overflow: clip;
  white-space: normal;
}
.scrollable-container {
  height: 300px; /* 设置容器高度 */
  overflow: auto; /* 添加滚动条 */
}
// .ant-input-disabled:hover {
//   background-color: #fff;
// }
.ant-input[disabled] {
  background-color: #fff;
  color: rgba(0, 0, 0, 0.85);
}
</style>

